View Builder (Available only in Enterprise Edition)

Navicat Data Modeler provides a useful tool called View Builder for building views visually. It allows you to create and edit views without knowledge of SQL. Even if you are familiar with SQL, the convenient and fluent graphical interface makes it easier to create relations and visualize the view.

In View Designer, click the View Builder button to open the visual View Builder.

All database objects are displayed on the left Object pane. Whereas on the middle pane, it is divided into two portions: the upper Diagram pane, and the lower Criteria pane. When building the view, you can view the auto-generated SQL on the right SQL pane.

Add Objects to View

The first step is to decide which tables and views you need to add to the view.

To add tables and views to the view, use one of the following methods:

You can set aliases for tables, views and subqueries by double-clicking the object title on the Diagram pane and entering the name to use as an alias for the object name.

After you have added objects to the diagram, you can use the FROM tab to adjust the view to your needs.

You can control-click an object on the Diagram pane and select Remove, or simply press DELETE key to remove the selected object from the view.

When you remove an object, View Builder automatically removes joins that involve that object.

Choose Output Fields

To include fields in the view, use one of the following methods:

The selected fields display on the SELECT tab. You can specify additional output field options.

Set Field Association

View Builder will automatically join the tables as per the foreign key relations. If you want to associate database objects manually, just select a field from an object and drag it to a field in another object. A connector line appears between the two objects to visually represent the relationship and the join type.

There are two views to show the connector lines: Table Relation and Field Relation. The Field Relation view allows you to identify matching fields in two tables, while the Table Relation view displays the join relationship between the two tables.

All joins are initially created as INNER JOIN by default. To change the association, click or double-click the connector line on the Diagram pane or click the JOIN keyword on the FROM tab, and then select a join type. If a join type is not listed, you can enter a customized one in the Custom textbox.

To remove a join, control-click the connector line and select Remove.

To modify the join condition, control-click a connector line and select Edit Join, or click the condition on the FROM tab.

The pop-up menu options of the FROM tab:

Option

Description

Insert

Add an identifier, an expression or a subquery.

Insert Bracket

Add a pair of parentheses.

Remove

Remove the identifier, expression or subquery.

Edit SQL

Edit the subquery.

Convert to Subquery

Convert the condition to a subquery.

Clear and Convert to USING Clause

Remove the ON condition and convert it to USING clause.

Clear and Convert to ON Clause

Remove the USING condition and convert it to ON clause.

Group with Bracket

Add parentheses to group the selected conditions.

Ungroup

Remove the parentheses.

Set Filter Criteria

When retrieving data, you may want to set up a filtering expression. To filter data returned by the view, control-click a field on the Diagram pane and select Add Field To -> WHERE and an operator.

The condition is added to the WHERE tab. You can edit the value there by clicking <Value>. If you want to add a condition with parentheses, click Add Parentheses. You can change a logical operator (and/or) by clicking it. Use the up arrow and down arrow buttons to change the order of conditions.

The pop-up menu options of the WHERE tab:

Option

Description

Toggle Negator

Reverse the meaning of the condition.

Insert

Add a condition.

Insert Custom

Add a custom condition.

Insert Bracket

Add a pair of parentheses.

Remove

Remove the condition.

Group with Bracket

Add parentheses to group the selected conditions.

Ungroup

Remove the parentheses.

Group Resulting Data

You can set the conditions for grouping records by control-clicking a field in the Diagram pane and selecting Add Field To -> GROUP BY -> Add Field.

The condition is added to the GROUP BY tab. Use the up arrow and down arrow buttons to change the order of fields.

On the HAVING tab, you can filter summarized data or grouped data. Select the identifiers, operators, aggregate or enter expressions to include in the condition. Use the up arrow and down arrow buttons to change the order of conditions.

The pop-up menu options of the HAVING tab:

Option

Description

Toggle Negator

Reverse the meaning of the condition.

Insert

Add a condition.

Insert Custom

Add a custom condition.

Insert Bracket

Add a pair of parentheses.

Remove

Remove the condition.

Group with Bracket

Add parentheses to group the selected conditions.

Ungroup

Remove the parentheses.

Sort Resulting Data

You can set the way of sorting records by control-clicking a field on the Diagram pane and selecting Add Field To -> ORDER BY -> ASC or DESC. The condition will be added to the ORDER BY tab.

Limit Resulting Data

On the LIMIT tab, you can limit your view results to those that fall within a specified range.

Offset

Specify the number of records to be skipped. It is optional.

Limit

Specify the number of records to be displayed.

Note: Available only for MySQL, PostgreSQL, SQLite and MariaDB.

Add Expressions/Subqueries

You can add an expression or a subquery to further limit the view results. On the FROM tab, click Add Field and select the Expression/Subquery tab.

After entered an expression or a subquery, confirm editing by pressing the ENTER key. It will be added to the Diagram pane indicates that the statement contains an expression or a subquery and identifies the columns it is on.

By clicking the View Builder button, you will be switched to a subquery layer where you can build it visually in the same way as the main query.

You can always go back to the main query by clicking (Main Query).

View Generated SQL

The SQL pane presents a read-only, formatted representation of the SQL generated by View Builder. You can copy the SQL that appears in the SQL pane for use in other tools. In a subquery layer, you can enable Show Current Layer Only to show the subquery SQL.